﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ABB_last_end.module;


namespace ABB_last_end
{
    public partial class main : Form
    {

        public main()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        // 密码初始化设置  
        string adr_id = "ABB";
        string opr_id = "abb";
        string adr_psw = "123456ABB";
        string opr_psw = "123456";

        //实例化连接类
        static ABB_connect aBB_Connect = new ABB_connect();

        // 分级登陆设计 
        private void btn_sign_Click(object sender, EventArgs e)
        {
 
            if (chB_adr.Checked)
            {
                if (txB_account.Text == adr_id && txB_password.Text == adr_psw)
                {
                    this.Hide();
                    aBB_Connect.connect_refresh_adm();
                    
                }
                else
                {
                    MessageBox.Show("账号或密码不对，请注意登陆模式！");
                }

            }
            else if (chB_opr.Checked)
            {
                if (txB_account.Text == opr_id && txB_password.Text == opr_psw)
                {  
                    this.Hide();
                    aBB_Connect.connect_refresh();
                }
                else
                {
                    MessageBox.Show("账号或密码不对，请注意登陆模式！");
                }
            }
            else
            {
                MessageBox.Show("请选择一种登陆方式哦！");
            }
        }

        // 登陆模式互锁设计 
        private void chB_adr_CheckedChanged(object sender, EventArgs e)
        {
            if (chB_adr.Checked)
            {
                if (chB_opr.Checked)
                {
                    MessageBox.Show("只能选择一种登陆模式哦！");
                    chB_opr.Checked = false;
                }

            }


        }

        private void chB_opr_CheckedChanged(object sender, EventArgs e)
        {
            if (chB_opr.Checked)
            {
                if (chB_adr.Checked)
                {
                    MessageBox.Show("只能选择一种登陆模式哦！");
                    chB_adr.Checked = false;
                }
            }
        }
    }
}
